# $Id$
#Maintainer: Gaetan Bisson <bisson@archlinux.org>
#Contributor: Tobias Powalowski <tpowa@archlinux.org>

pkgname=unison
pkgver=2.48.4
pkgrel=2
pkgdesc='File-synchronization tool'
url='https://www.cis.upenn.edu/~bcpierce/unison/'
arch=('i686' 'x86_64')
license=('GPL2')
optdepends=('gtk2: for gtk2 support')
makedepends=('ocaml' 'lablgtk2' 'imagemagick')
source=("https://www.cis.upenn.edu/~bcpierce/unison/download/releases/${pkgname}-${pkgver}/${pkgname}-${pkgver}.tar.gz"
        'large.patch'
        'desktop')
sha1sums=('baeff0e3a942c710ce551cca118b891feca137c5'
          '95433c2aa961cba19535fdf556e30bafa414a420'
          '9dad1737dd8d90e7ee2744a96cf71bd9f802a12a')

options=('!makeflags')

prepare() {
	cd "${srcdir}/src"
	patch -p0 -i ../large.patch
}

build() {
	cd "${srcdir}/src"
	CFLAGS=""

	for ui in text gtk2; do
		make clean
		make mkProjectInfo 
		make UISTYLE=$ui DEBUGGING=false THREADS=true
		mv unison unison-$ui
	done
}

package() {
	cd "${srcdir}/src"

	install -d "${pkgdir}"/usr/bin
	install -m755 unison-* "${pkgdir}"/usr/bin

	install -d "${pkgdir}"/usr/share/{pixmaps,applications}
	convert win32rc/U.ico[1] "${pkgdir}/usr/share/pixmaps/${pkgname}.png"
	install -m644 ../desktop "${pkgdir}/usr/share/applications/${pkgname}.desktop"

	cd "${pkgdir}"/usr/bin
	ln -s unison-text unison
	ln -s unison-gtk2 unison-x11
	ln -s unison unison-${pkgver%.*}
}
